import Vue from 'vue'
import VueRouter from 'vue-router'

// 防止重复触发同一个路由
const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter)

const routes = [{

        path: '/',
        component: () =>
            import ('@/views/index/Index.vue'),
        name: 'index',
        redirect: '/article',
        children: [{
                path: "/article",
                component: () =>
                    import ('@/views/article/Article.vue'),
                name: 'article'
            },
            {
                path: "/search",
                component: () =>
                    import ('@/views/search/Search.vue'),
                name: 'search'
            },
            {
                path: "/about",
                component: () =>
                    import ('@/views/about/About.vue'),
                name: 'about'
            },
            {
                path: "/type",
                component: () =>
                    import ('@/views/type/Type.vue'),
                name: 'type'
            },
            {
                path: "/typeList",
                component: () =>
                    import ('@/views/type/typeList.vue'),
                name: 'typeList'
            },
            {
                path: "/questions",
                component: () =>
                    import ('@/views/questions/Questions.vue'),
                name: 'questions'
            },

            {
                path: "/question-info",
                component: () =>
                    import ('@/views/question-info/Question-info.vue'),
                name: 'question-info'
            },
            {
                path: "/tag",
                component: () =>
                    import ('@/views/tag/Tag.vue'),
                name: 'tag'
            },
            {
                path: "/archive",
                component: () =>
                    import ('@/views/archive/Archive.vue'),
                name: 'archive'
            },
            {
                path: "/articleDetail",
                component: () =>
                    import ('@/views/article/ArticleDetail.vue'),
                name: 'articleDetail'
            },
            {
                path: "/resource",
                component: () =>
                    import ('@/views/resource/Resource.vue'),
                name: 'resource'
            },
            {
                path: "/subject",
                component: () =>
                    import ('@/views/subject/Subject.vue'),
                name: 'subject'
            }
        ]
    },

]

const router = new VueRouter({
    routes
})

export default router